<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />

<!-- easyui -->
<script type="text/javascript" th:src="@{/easyui/jquery.min.js}" ></script>
<script type="text/javascript" th:src="@{/easyui/jquery.easyui.min.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/default/easyui.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/icon.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/color.css}">
	<script type="text/javascript" th:src="@{/easyui/locale/easyui-lang-zh_CN.js}"></script>
</head>
<body>
	<!-- 工具条 --> 
	<div th:replace="commons/pub::#list"></div>
	<div th:replace="commons/pub::#tool_bar"></div>
	<!-- 编辑窗口 -->
	<div id="win">
		<form id="editForm" method="post">
			实验编号：<input name="oeId" type="number" class="easyui-validatebox" data-options="required:true"/><br>
			课程编号：<input name="oeNo" class="easyui-validatebox" data-options="required:true"/><br>
			申请人编号：<input name="oeAId" class="easyui-validatebox" data-options="required:true"/><br>
			申请人姓名：<input name="oeAName" class="easyui-validatebox" data-options="required:true"/><br>
			导师编号:<input name="mentorId" class="easyui-validatebox" data-options="required:true"/><br>
			导师姓名:<input name="mentorName" class="easyui-validatebox" data-options="required:true"/><br>
			实验标题:<input name="oeTitle" class="easyui-validatebox" data-options="required:true"/><br>
			实验内容:<input name="oeContent" class="easyui-validatebox" data-options="required:true"/><br>
			实验室编号:<input name="labId" class="easyui-validatebox" /><br>
			预约日期：<input name="orderedLab.oDate" class="easyui-validatebox" /><br>
			预约时段：<input name="orderedLab.timeId" class="easyui-validatebox" /><br>
			导师审核:<input name="taState" type="radio" class="easyui-validatebox" value="1"/>通过
			<input name="taState" type="radio" class="easyui-validatebox"  value="0"/>未通过
			<input name="taState" type="radio" class="easyui-validatebox"  value=""/>待审核<br>
			导师审核时间：<input name="taTime" class="easyui-validatebox" /><br>
			实验管理员审核:<input name="laState" type="radio" class="easyui-validatebox" value="1"/>通过
			<input name="laState" type="radio" class="easyui-validatebox"  value="0"/>未通过
			<input name="laState" type="radio" class="easyui-validatebox"  value=""/>待审核<br>
			实验管理员审核时间：<input name="laTime" class="easyui-validatebox" /><br>
			创建时间:<input name="createTime" class="easyui-validatebox" /><br>

			<a id="saveBtn" href="" class="easyui-linkbutton">保存</a>
		</form>
	</div>
	<script type="text/javascript" th:inline="none">
	$(function(){
		$('#oeDate').calendar({
			current:new Date()
		});
		$('#list').datagrid({   
		    url:'/oex/listByPage',
		    columns:[[   
		        {field:'id',title:'编号',checkbox:true},
		        {field:'oeId',title:'实验编号',width:'10%',align:'center'},
		        {field:'oeNo',title:'课程编号',width:'10%',align:'center'},
		        {field:'oeTitle',title:'实验标题',width:'20%',align:'center'},
		        {field:'oeAName',title:'申请人姓名',width:'10%',align:'center'},
				{field:'mentorName',title:'导师姓名',width:'20%',align:'center'},
				{field:'taState',title:'导师审核',width:'10%',align:'center'},
				{field:'laState',title:'实验管理员审核',width:'10%',align:'center'}
		    ]],
		    pagination:true,
		    toolbar:"#tool_bar"
		}); 
		$('#win').window({
		    width:600,   
		    height:400, 
		    padding:30,
		    closed:true,
		    title:"用户编辑",
		    modal:true  
		});
		//查看更多
		$("#moreBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length!=1){
				$.messager.alert("提示","修改操作只能选择一行","warning");
				return;
			}
			//表单回显
			$("#editForm").form("load","/oex/findOexById?oeId="+rows[0].oeId+"");
			$("#editForm input").attr("readonly","readonly");
			$("#win").window("open");
		});
		/*增加用户*/
		$("#addBtn").click(function(){
			$("#editForm").form("clear");
			$("#win").window("open");
		});
		/*保存*/
		$("#saveBtn").click(function () {
			$("#editForm").form("submit",{
				url:"/oex/saveOexperiment",     //提交表单
				onSubmit:function(){
					return $("#editForm").form("validate");
				},
				success:function(data){   //回传数据
					data=eval("("+data+")")
					if(data.success){
						$("#win").window("close");
						$("#list").datagrid("reload");
						$.messager.alert("提示","保存成功!","info");
					}else{
						$.messager.alert("提示","保存失败！",data.msg,"error");
					}
				}
			});
		})
		//修改数据
		$("#editBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length!=1){
				$.messager.alert("提示","修改操作只能选择一行","warning");
				return;
			}
			//清空上次的数据
			$("#editForm").form("reset");
			//表单回显
			$("#editForm").form("load","/oex/findOexById?oeId="+rows[0].oeId+"");
			$("#win").window("open");
		});
		//删除功能
		$("#deleteBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length==0){
				$.messager.alert("提示","删除操作至少选择一行","warning");
				return;
			}
			$.messager.confirm("提示","确定删除吗？",function(value){
				if(value){
					//执行删除,遍历数据
					var idStr= "";
					$(rows).each(function(i){
						idStr+=("oeId="+rows[i].oeId);
						if(i!=$(rows).length-1){
							idStr+="&";
						}
					});
					$.post("/oex/delectOexperiment",idStr,function(data){
						if(data.success){
							$("#list").datagrid("reload");
							$.messager.alert("提示","删除成功!","info");
						}else{
							$.messager.alert("提示","删除失败：",data.msg,"error");
						}
					},"json");
				}
			});
		});
	});
	</script>

</body>